home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / newsgate / mkmailpost.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  1991-07-18  |  1.2 KB  |  55 lines

  1. #! /bin/sh
  2. ##  $Header: /nfs/papaya/u2/rsalz/src/newsgate/RCS/mkmailpost.sh,v 1.4 91/02/12 14:49:26 rsalz Exp $
  3. ##  Script to make a set of "mailpost" commands for all groups in
  4. ##  the news active file.
  5. ##  Usage:
  6. ##    makemailpost [news active file [mail2newspath] ]
  7.  
  8. case $# in
  9. [012])
  10.     ;;
  11. *)
  12.     echo "Usage: `basename $0` [activefile [mail2newspath] ]" 1>&2
  13.     exit 1
  14.     ;;
  15. esac
  16.  
  17. ACTIVE=${1-/usr/lib/news/active}
  18. if [ ! -f ${ACTIVE} ] ; then
  19.     echo "`basename $0`:  Can't read input ${ACTIVE}." 1>&2
  20.     exit 1
  21. fi
  22.  
  23. ##  Write the prolog.
  24. echo "/*"
  25. echo "**  Generated from ${ACTIVE}"
  26. echo "**  by `whoami` on `date`"
  27. echo "*/"
  28. if [ "$2" != "" ] ; then
  29.     echo 'default mail2news "'$2'";'
  30. fi
  31.  
  32. trap "rm -f /tmp/mmp$$ ; exit 1" 1 2 3 15
  33.  
  34. ##  Create the sed temporary file and run it
  35. cat >/tmp/mmp$$ <<\EOF
  36. # Delete moderated groups
  37. /m$/d
  38. # Trim anything after the first field
  39. s/ .*$//
  40. # Delete control, junk, site-specific
  41. /^control$/d
  42. /^junk$/d
  43. /^to\./d
  44. # Delete test groups and announce, assuming the latter is moderated
  45. /\<test\>/d
  46. /\<announce\>/d
  47. # Turn the line "foo" into "mailpost foo;"
  48. s/^.*$/mailpost &;/
  49. EOF
  50.  
  51. ##  Run sed, clean up.
  52. sed -f /tmp/mmp$$ <${ACTIVE} | sort
  53.  
  54. rm -f /tmp/mmp$$
  55.